<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>

</body>
<script>
  // this 函数内置的关键词 , 在调用时指向函数依存的对象
  // 1. 一般情况下,普通函数(命名函数和匿名函数) =>指向window(严格模式下 undefined)
  // 2. 函数在调用时 属于谁就指向谁

  function fn() {
    console.log(this);
  }
  // fn();

  var zhang = {
    name: "张三",
    age: 18,
    say: function () {
      console.log(this);
      console.log(this.name, this.age);
    }
  }

  zhang.say();

  var { say } = zhang;  // var say = zhang.say;
  // var say = function(){
  //     console.log(this);
  //     console.log(this.name,this.age);
  // }
  say();


  document.onclick = function () {
    console.log(this);
  }




</script>

</html>